﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

using DeviceInfoManage.BusinessLogicLayer;
public partial class DeviceTypeEdit : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if(!IsPostBack)
        {
            if (Session["adminUserName"] == null)
            {
                Response.Redirect("login.aspx");
            }
            /*窗体首次载入时根据设备类别编号获取设备类别名称并加入到文本框中*/
            string deviceTypeId = Request.QueryString["deviceTypeId"];
            this.DeviceTypeName.Text = (new DeviceType()).GetDeviceTypeName(Int32.Parse(deviceTypeId));
        }

    }
    protected void Btn_Update_Click(object sender, EventArgs e)
    {
        string deviceTypeId = Request.QueryString["deviceTypeId"];
        string deviceTypeName = this.DeviceTypeName.Text;
        DeviceType deviceType = new DeviceType();
        if (!deviceType.UpdateDeviceType(Int32.Parse(deviceTypeId), deviceTypeName))
            Response.Write("<script>alert('" + deviceType.ErrMessage + "');</script>");
        else
            Response.Write("<script>alert('修改成功!');location.href='DeviceTypeManage.aspx';</script>");
    }
}
